/**
 * @file    If_com.h 
 * @brief   COM口接口
 * @author  Liuwei
 * @version 1.0.1
 * @date    2023-04-20
 * 
 * @copyright Copyright (c) 2023 JBD-Energy Storage Technology Co. LTD
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version   <th>Author   <th>Description
 * <tr><td>2023-04-20 <td>1.0.1     <td>Liuwei   <td>首次创建
 * </table>
 */

#ifndef __IF_COM_H_
#define __IF_COM_H_

/* file includes -------------------------------------------------------------*/
#include <stdint.h>
/* cplusplus -----------------------------------------------------------------*/
#define COM_RX_BUF_SIZE           (2048)
#define COM_TX_BUF_SIZE           (256)

#ifdef __cplusplus
extern "C" {
#endif

/* macro/define/typedef ------------------------------------------------------*/
enum
{
    COM_PARALLEL , 
    COM_PCS      ,
    COM_LCD      ,
    COM_BLUE     ,
	COM_GPS      ,
	COM_RS232    ,
	
    COM_ID_MAX   , 
};

typedef struct
{
	uint16_t tx_num ;
	uint16_t rx_num ;
	uint8_t tx_buf[COM_TX_BUF_SIZE];
	uint8_t rx_buf[COM_RX_BUF_SIZE];
}com_data_type;
/* @brief */

/* variables -----------------------------------------------------------------*/

/*******************************************************************************
 * public API List
 ******************************************************************************/
void If_com_cfg_init(void);
void If_com_init_drv(uint8_t com_id , uint32_t baudrate);
void If_com_uart_recv_irq(uint8_t com_id , uint8_t data);
void If_com_time_irq(uint32_t time);
uint8_t If_com_recv_comp(uint8_t com_id);
uint16_t If_com_get_recv_num(uint8_t com_id);
uint16_t If_com_get_recv_buf(uint8_t com_id ,uint8_t *data_buf ,uint16_t recv_num);
void If_com_send_str(uint8_t com_id , uint8_t *send_buf , uint16_t send_size);
void If_com_start_recv(uint8_t com_id);
void If_com_reset_recv(uint8_t com_id);
void If_com_deinit(uint8_t com_id);

#ifdef __cplusplus
}
#endif

#endif  /* #ifndef __IF_COM_H_ */
/********** Copyright (c) 2023 JBD-Energy Storage Technology Co. LTD *********/
